<form id="form_add_project_basic_in_m83" enctype="multipart/form-data" method="post" action="#" class="form">
    <input type="hidden" name="datagrid_code" value="project_basic_m83">
    <div class="wrapper-form">
        <div id="form_content_add_project_basic_in_m83">

        </div>
        <dl class="row">
            <dt class="tit">
                <label>操作</label>
            </dt>
            <dd class="opt">
                <label><input type="radio" value="1" name="operation" checked="checked" >新增</label>
                <label><input type="radio" value="2"  name="operation" >升版</label>
            </dd>
        </dl>
        <div id="m83_form_row_project_name_1">
            <dl class="row" >
                <dt class="tit">
                    <label></label>
                </dt>
                <dd class="opt">
                    <input type="text" name="project_name"  class="input-txt" />
                </dd>
            </dl>
        </div>
        <div id="m83_form_row_project_name_2" class="hide">
            <dl class="row" >
                <dt class="tit">
                    <label></label>
                </dt>
                <dd class="opt">
                    <input type="text"  name="project_trunk_id" class="input-txt" />
                </dd>
            </dl>
        </div>
    </div>
</form>
<script>
    $(function(){
        var subjectKeyword = "project_basic_in_m83";
        var idPrefix = "#m83_form_row_project_name_";
        var formId = "#form_add_" + subjectKeyword;
        var projectList = getProjectTrunkList();
        var ptConfig = {
            data: projectList,
            textField: 'project_name',
            valueField: 'id'
        };
        $(formId + " input[name=project_trunk_id]").combobox(ptConfig);

        $(formId + " input[name=operation]").click(function(){
            var curItem = $(this);
            var curValue = curItem.val();
            var targetBoxId = idPrefix + curValue;
            var anotherVal = 1 == curValue ? 2:1;
            var anotherBox = idPrefix + anotherVal;
            $(targetBoxId).removeClass("hide");
            $(anotherBox).addClass("hide");
        });

        function getProjectTrunkList()
        {
            var projectList = [];
            $.ajax({
                url:'/api/ProjectTrunk/getProjectTrunkOption',
                type:'post',
                data: {},
                dataType:'json',
                async:false,
                success:function(resp){
                    if(0 == resp.code){
                        layer.msg(resp.message);
                    }else {
                        projectList = resp.data;
                    }
                }
            });
            return projectList;
        }
    });
</script>